

    \filetitle{dbfun}{Apply function to database fields}{dbase/dbfun}

	\paragraph{Syntax}

Input arguments marked with a \texttt{\textasciitilde{}} (tilde) sign
may be omitted.

\begin{verbatim}
[D,Flag,ErrList,WarnList] = dbfun(Func,D,...)
[D,Flag,ErrList,WarnList] = dbfun(Func,D,~D2,~D3,...,~Dk,...)
\end{verbatim}

\paragraph{Input arguments}

\begin{itemize}
\item
  \texttt{Func} {[} function\_handle \textbar{} char {]} - Function that
  will be applied to each field.
\item
  \texttt{D} {[} struct {]} - Primary input database whose fields will
  be processed by the function \texttt{Func}.
\item
  \texttt{\textasciitilde{}D2}, \texttt{\textasciitilde{}D3}, \ldots{}
  {[} struct {]} - Secondary input databases whose fields will be passed
  into \texttt{Func} (\texttt{Func} accepts more than one input
  argument).
\end{itemize}

\paragraph{Output arguments}

\begin{itemize}
\item
  \texttt{D} {[} struct {]} - Output database whose fields will be
  created by applying \texttt{Func} to each field of the input database
  or databases.
\item
  \texttt{Flag} {[} \texttt{true} \textbar{} \texttt{false} {]} - True
  if no error occurs when evaluating the function.
\item
  \texttt{ErrList} {[} cellstr {]} - List of fields on which the
  function has thrown an error.
\item
  \texttt{WarnList} {[} cellstr {]} - List of fields on which the
  function has thrown a warning.
\end{itemize}

\paragraph{Options}

\begin{itemize}
\item
  \texttt{\textquotesingle{}subdbase=\textquotesingle{}} {[}
  \emph{\texttt{true}} \textbar{} \texttt{false} {]} - Go through all
  sub-databases (i.e.~struct fields within the input struct), applying
  the function \texttt{Func} to their fields, too.
\item
  \texttt{\textquotesingle{}classFilter=\textquotesingle{}} {[} cell
  \textbar{} cellstr \textbar{} rexp \textbar{} \emph{\texttt{@all}} {]}
  - Apply \texttt{Func} only to database fields whose class is on the
  list or matches the regular expression; \texttt{@all} means all fields
  in the input database \texttt{D} will be processed.
\item
  \texttt{\textquotesingle{}fresh=\textquotesingle{}} {[} \texttt{true}
  \textbar{} \emph{\texttt{false}} {]} - Remove unprocessed entries from
  the output database.
\item
  \texttt{\textquotesingle{}nameList=\textquotesingle{}} {[} cell
  \textbar{} cellstr \textbar{} rexp \textbar{} \emph{\texttt{@all}} {]}
  - Apply \texttt{Func} only to this list of database field names or
  names that match this regular expression; \texttt{@all} means all
  entries in the input database \texttt{D} wil be processed.
\item
  \texttt{\textquotesingle{}ifError=\textquotesingle{}} {[}
  \texttt{\textquotesingle{}NaN\textquotesingle{}} \textbar{}
  \emph{\texttt{\textquotesingle{}remove\textquotesingle{}}} {]} - What
  to do with the database entry if an error occurs when the entry is
  being evaluated.
\item
  \texttt{\textquotesingle{}ifWarning=\textquotesingle{}} {[}
  \emph{\texttt{\textquotesingle{}keep\textquotesingle{}}} \textbar{}
  \texttt{\textquotesingle{}NaN\textquotesingle{}} \textbar{}
  \texttt{\textquotesingle{}remove\textquotesingle{}} {]} - What to do
  with the database entry if an error occurs when the entry is being
  evaluated.
\end{itemize}

\paragraph{Description}

\paragraph{Example}

\begin{verbatim}
d = struct( );
d.a = [1, 2];
d.b = tseries(1:3,@ones);
d = dbfun( @(x) 2*x, d)

d = 
    a: [2 4]
    b: [3x1 tseries]

d.b
ans = 
    tseries object: 3-by-1
    1:  2
    2:  2
    3:  2
    ''
    user data: empty
    export files: [0]
\end{verbatim}


